package com.nkzy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.nkzy.domain.pojo.Emp;
import com.nkzy.service.EmpService;

import java.util.List;

@RestController
@RequestMapping("/emp")
@CrossOrigin
public class EmpController {

    @Autowired
    private EmpService empService;

    @PostMapping("/save")
    public boolean save(@RequestBody Emp emp) {
        return empService.save(emp);
    }

    @GetMapping("/getById/{id}")
    public Emp getById(@PathVariable Long id) {
        return empService.getById(id);
    }

    @DeleteMapping("/removeById/{id}")
    public boolean removeById(@PathVariable Long id) {
        return empService.removeById(id);
    }

    @GetMapping("/listByIds")
    public List<Emp> listByIds(@RequestParam List<Long> ids) {
        return empService.listByIds(ids);
    }

    @GetMapping("/list")
    public List<Emp> list() {
        return empService.list();
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Emp emp) {
        return empService.updateById(emp);
    }
}